
package de.fhhof.brst.event;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import de.fhhof.brst.dao.EventDAO;
import de.fhhof.brst.dao.HibernateEventDAO;
import de.fhhof.brst.data.Booking;
import de.fhhof.brst.data.Event;
import de.fhhof.brst.data.Ticket;
import de.fhhof.brst.session.SessionBean;
@ManagedBean
@RequestScoped
public class Tickets implements Serializable {
  /**
   * 
   */
  private static final long serialVersionUID =  -8082343390432340085L;

  private de.fhhof.brst.data.Ticket ticket;

  private List<de.fhhof.brst.data.Ticket> ticketList =  new ArrayList<Ticket>();

  private List<de.fhhof.brst.data.Event> tickets =  new ArrayList<Event>();

  private de.fhhof.brst.dao.EventDAO eventDAO =  HibernateEventDAO.getHibernateEventDAO();

  @ManagedProperty(value = "#{sessionBean}")
  private de.fhhof.brst.session.SessionBean sessionBean;

  public Tickets() {
		
  }

  @PostConstruct
  public void init() {
		ticketList = eventDAO.getTickets(sessionBean.getUser().getId());
		Event event;
		
		for (Ticket ticket : ticketList) {
			event = eventDAO.getEvent(ticket.getEvent_id());
			tickets.add(event);
		}
  }

  public de.fhhof.brst.data.Ticket getTicket() {
		return ticket;
  }

  public void setTicket(de.fhhof.brst.data.Ticket ticket) {
		this.ticket = ticket;
  }

  public List<de.fhhof.brst.data.Ticket> getTicketList() {
		return ticketList;
  }

  public void setTicketList(List<Ticket> ticketList) {
		this.ticketList = ticketList;
  }

  public de.fhhof.brst.dao.EventDAO getEventDAO() {
		return eventDAO;
  }

  public void setEventDAO(de.fhhof.brst.dao.EventDAO eventDAO) {
		this.eventDAO = eventDAO;
  }

  public de.fhhof.brst.session.SessionBean getSessionBean() {
		return sessionBean;
  }

  public void setSessionBean(de.fhhof.brst.session.SessionBean sessionBean) {
		this.sessionBean = sessionBean;
  }

  public List<de.fhhof.brst.data.Event> getTickets() {
		return tickets;
  }

  public void setTickets(List<Event> tickets) {
		this.tickets = tickets;
  }

}
